/**
 * @author Administrator
 */
/**
 * @author Administrator
 *
 */
package com.sgy;

import java.io.IOException;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

/**
 *
 */
public class Server {

    static final int listenPort = 8888;

    static final String listenIP = "0.0.0.0";

    public void await() {
        try (ServerSocket serverSocket = new ServerSocket(listenPort, 1, InetAddress.getByName(listenIP))) {
            while (true) {
                Socket socket;
                try {
                    socket = serverSocket.accept();
                    socket.setKeepAlive(true);

                    ServerProxy sp = new ServerProxy(socket);
                    Thread t = new Thread(sp);
                    t.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}